using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;
namespace BUS
{
   public class tbLuuyBUS
    {
        public static void Insert(tbLuuy ly)
        {
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            lyDAL.Insert(ly);
        }
        public static void Update(tbLuuy ly)
        {
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            lyDAL.Update(ly);
        }
        public static void Delete(int iD)
        {
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            lyDAL.Delete(iD);
        }
        public static tbLuuyCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            return lyDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLuuyCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            return lyDAL.Get(cri.Criter, 0, 0, tbDanhmucColumn.Madanhm.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbLuuy GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbLuuyColumn.Maluuy.ToString(), Condition.EQUAL, iD);
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            tbLuuyCollection lyCollection = lyDAL.Get(cri.Criter, 0, 0, tbLuuyColumn.Maluuy.ToString(), OrderDirection.ASC.ToString(), out total);
            if (lyCollection.Count > 0)
                return lyCollection[0];
            return null;
        }
        public static tbLuuyCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            return lyDAL.Get(cri.Criter, 1, number,
            tbLuuyColumn.Maluuy.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbLuuyCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLuuyDAL lyDAL = new tbLuuyDAL();
            return lyDAL.Get(cri.Criter, 1, number,
            tbLuuyColumn.Maluuy.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
